#!/bin/bash

WIKIDIR=/home/httpd
BACKUPDIR=/home/backups
BACKUPDIR_OLD=/home/backups/old

SEQ=`date +%Y%m%d-%H%M`

find $WIKIDIR -maxdepth 1 -name '*wiki*' | while read a; do tar -cvzf $a$SEQ.tgz $a; done
find $WIKIDIR -maxdepth 1 -name '*.tgz' | while read a; do mv -v $a $BACKUPDIR; done

if [ ! -e $BACKUPDIR_OLD ]; then
	mkdir $BACKUPDIR_OLD
fi

find $BACKUPDIR -maxdepth 1 -type f -name "*.tgz" -cmin +90 -exec mv {} $BACKUPDIR_OLD
find /home/backups/ -type f -name "*.tgz" -ctime +1 -delete
